// const mqtt = require('mqtt')
import dayjs from "dayjs";

let token = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3VzZXJkYXRhIjoie1wiVXNlcklkXCI6XCIyMjU1MjczMS0wZWY4LWVmMTEtYjUwNS05MWRlN2I0ZWVjMzJcIixcIkFjY291bnRcIjpcImd4Z2RAZW5lcmd5cGVjLmNuXCIsXCJDb21wYW55SWRcIjpcIjIwNTUyNzMxLTBlZjgtZWYxMS1iNTA1LTkxZGU3YjRlZWMzMlwiLFwiUm9sZUlkXCI6XCIyMTU1MjczMS0wZWY4LWVmMTEtYjUwNS05MWRlN2I0ZWVjMzJcIixcIkFjY291bnRUeXBlXCI6MSxcIkRhdGFQcmVjaXNpb25cIjoyfSIsIm5iZiI6MTc1NTU2MjkxMSwiZXhwIjoxNzU4MjQxMzExLCJpYXQiOjE3NTU1NjI5MTEsImlzcyI6InNlbGYiLCJhdWQiOiJhbGwifQ.lrgpK1VmaetVHQo9rX69V7llbu288L1ALkyE6dyI0Ds";

const getUserList = () => {

  let tokens = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3VzZXJkYXRhIjoie1wiVXNlcklkXCI6XCIyMjU1MjczMS0wZWY4LWVmMTEtYjUwNS05MWRlN2I0ZWVjMzJcIixcIkFjY291bnRcIjpcImd4Z2RAZW5lcmd5cGVjLmNuXCIsXCJDb21wYW55SWRcIjpcIjIwNTUyNzMxLTBlZjgtZWYxMS1iNTA1LTkxZGU3YjRlZWMzMlwiLFwiUm9sZUlkXCI6XCIyMTU1MjczMS0wZWY4LWVmMTEtYjUwNS05MWRlN2I0ZWVjMzJcIixcIkFjY291bnRUeXBlXCI6MSxcIkRhdGFQcmVjaXNpb25cIjoyfSIsIm5iZiI6MTc1NTU2MjkxMSwiZXhwIjoxNzU4MjQxMzExLCJpYXQiOjE3NTU1NjI5MTEsImlzcyI6InNlbGYiLCJhdWQiOiJhbGwifQ.lrgpK1VmaetVHQo9rX69V7llbu288L1ALkyE6dyI0Ds";

  const params = new URLSearchParams();

  params.append("mfid", '0750fa0d-7c63-f011-b591-c601f6bae5df');
  params.append("time", '2025-07');
  params.append("unit", 'm³');

  let url = 'http://111.8.86.3:19126/api/largeCustomer/operationManagement/meterRealTimeDataTable?' + params.toString();
  return fetch(url, {
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
      'Accept': 'application/json, text/plain, */*',
      'Authorization': 'ddddd',
      'Host': 'www.zghaohua.com:8089',
      'Origin': 'http://www.zghaohua.com:100',
      'Referer': 'http://www.zghaohua.com:100/',
    }
  })
    .then((response) => {
      console.log('2222222', response)
      return response.json();
    })
    .then((data) => {
      console.log(data, '00000');

    })
    .catch((error) => console.error('error:', error));
}



const getData = async () => {
  const url = 'http://www.zghaohua.com:8089/api/watersystem/gettotalamount?dateType=1'
  return fetch(url, {
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
      'Accept': 'application/json, text/plain, */*',
      'Authorization': token,
      'Cookie': `Authorization=${token};`
    }
  })
    .then((response) => {
      console.log('1111111', response)
      return response.json();
    })
    .then((data) => {
      console.log('======', data)
    })
    .catch((error) => console.error('error:', error));
};

getData()
getUserList()